import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JColorChooser;
import javax.swing.JLabel;
import javax.swing.colorchooser.ColorSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

class MyPreviewPane extends JLabel {
	Color curColor;

	public MyPreviewPane(JColorChooser chooser) {
		curColor = chooser.getColor();
		ColorSelectionModel model = chooser.getSelectionModel();
		model.addChangeListener(new ChangeListener() {
			public void stateChanged(ChangeEvent evt) {
				ColorSelectionModel model = (ColorSelectionModel) evt
						.getSource();
				curColor = model.getSelectedColor();
			}
		});
		setPreferredSize(new Dimension(50, 50));
	}

	public void paint(Graphics g) {
		g.setColor(curColor);
		g.fillRect(0, 0, getWidth() - 1, getHeight() - 1);
	}
}
